<#include "admin/home.html"/>
<#macro main>
<h3 class="field-title">编辑问题</h3>
<div class="m-form">
    <form id="dataForm">
        <input type="hidden" name="id" value="${vo.id}">
        <div class="formitm">
            <label class="lab">问题：</label>
            <div class="ipt">
                <input type="text" name="content" placeholder="请输入问题" value="${vo.content!}" required/>
            </div>
        </div>
        <div class="formitm">
            <label class="lab">答案解说：</label>
            <div class="ipt">
                <input type="text" name="narrate" placeholder="请输入答案解说" value="${vo.narrate!}" required/>
            </div>
        </div>
        <div class="formitm">
            <label class="lab">启用：</label>
            <div class="ipt">
                <label class="iSwitch">
                    <input type="checkbox" name="enabled" <#if vo.enabled == 1>checked="checked"</#if> value="1">
                    <i></i>
                </label>
            </div>
        </div>
        <#if vo.optionsList?? && vo.optionsList?size gt 0>
        <#list vo.optionsList as options>
        <div class="formitm ans">
            <label class="lab">答项：</label>
            <div class="ipt">
                <input type="text" class="options" name="options" placeholder="请输入答项" value="${options.name!}" required/>
                <label class="iSwitch">
                    <input type="radio" name="correct" <#if options.correct == 1>checked="checked"</#if> />
                    <i></i>
                </label>
                <#if !options_has_next>
                <img src="${resCtx}/images/admin/ico-add.png" class="add" onclick="addItem(this)"/>
                </#if>
                <#if vo.optionsList?size gt 1>
                    <img src="${resCtx}/images/admin/ico-sub.png" class="rem" onclick="removeItem(this)"/>
                </#if>
            </div>
        </div>
        </#list>
        <#else>
        <div class="formitm ans">
            <label class="lab">答项：</label>
            <div class="ipt">
                <input type="text" class="options" name="options" placeholder="请输入答项" required/>
                <label class="iSwitch">
                    <input type="radio" name="correct"/>
                    <i></i>
                </label>
                <img src="${resCtx}/images/admin/ico-add.png" class="add" onclick="addItem(this)"/>
            </div>
        </div>
        </#if>
        <div class="formitm formitm-1">
            <span class="btn" onclick="doSubmit()">提交</span>
        </div>
    </form>
</div>

<div id="item-tpl" style="display: none">
    <div class="formitm ans">
        <label class="lab">答项：</label>
        <div class="ipt">
            <input type="text" class="options" name="options" placeholder="请输入答项" required/>
            <label class="iSwitch">
                <input type="radio" name="correct" />
                <i></i>
            </label>
            <img src="${resCtx}/images/admin/ico-add.png" class="add" onclick="addItem(this)"/>
            <img src="${resCtx}/images/admin/ico-sub.png" class="rem" onclick="removeItem(this)"/>
        </div>
    </div>
</div>
</#macro>

<#macro tplJs>
    <script type="text/javascript" src="${resCtx}/js/admin/question.js"></script>
</#macro>